<?php
	include("initialize.php");
?>
<html>
<head>
	<title>GradeGrid - Account Settings</title>
	<?php include("header.php"); ?>
</head>
<body onLoad="writeCopyright()" onUnload="if (win && win.open && !win.closed) win.close()">
	<div class="main">
		
		<?php include("boilerplate.php"); ?>
		<?php include("loginnavigation.php"); ?>
        <?php include("fetchData.php"); ?>
		
		<?php if($_SESSION["logged_in"]): ?>
			<div style="float: left;">
                <span><a href="accountSettingsP.php">Personal Settings</a> | <a href="accountSettingsS.php">School Settings</a> | Class Settings</span>
                <hr />
                <h1>Templates <input type="button" value="Create a New Template" onClick="win=window.open('addTemplate.php','Create New Template','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0');"></h1>
				<?php $result=fetchAccountTemplateJoin(); ?>
                <?php if(mysql_num_rows($result)==0){?>
                    <span>You do not have any templates yet.</span>
                <?php } else {?>
                    <table><ul>
                    <?php while($data=mysql_fetch_array($result))
                        echo "<tr><td><li>".$data['template_name']."</td><td><input type=\"button\" name=\"edit\" value=\"Edit\" onclick=\"win=window.open('editTemplate.php?template_id=".$data['template_id']."','Create New Template','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0')\"></td><td><input type=\"button\" name=\"delete\" value=\"Delete\" onclick=\"window.location='deleteTemplate.php?template_id=".$data['template_id']."'\"></li></td></tr>"
                    ?>
                    </ul></table>
                <?php }?>
			</div>
		<?php else: ?>
			<?php executeFile("../files/access_error.txt"); ?>
		<?php endif ?>
        <?php mysql_close();?>
	</div>
	<div id="copywright"></div>
</body>
</html>